
'===============================================================================
'  Generated From - VbNet_SQL_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  **
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.3.0.3)

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

NameSpace Class_RC

Public MustInherit Class _PRODUCTOS
	Inherits SqlClientEntity

		Public Sub New() 
			Me.QuerySource = "PRODUCTOS"
			Me.MappingName = "PRODUCTOS"
		End Sub

	'=================================================================
	'  Public Overrides Sub AddNew()
	'=================================================================
	'
	'=================================================================
	Public Overrides Sub AddNew()
		MyBase.AddNew()
				
	End Sub
	
	Public Overrides Sub FlushData()
		Me._whereClause = nothing
		Me._aggregateClause = nothing		
		MyBase.FlushData()
	End Sub
	
		
	'=================================================================
	'  	Public Function LoadAll() As Boolean
	'=================================================================
	'  Loads all of the records in the database, and sets the currentRow to the first row
	'=================================================================
	Public Function LoadAll() As Boolean
	
		Dim parameters As ListDictionary = Nothing
		
		
    	Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_PRODUCTOSLoadAll]", parameters)
		
	End Function

	'=================================================================
	' Public Overridable Function LoadByPrimaryKey()  As Boolean
	'=================================================================
	'  Loads a single row of via the primary key
	'=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal CodProducto As Integer) As Boolean

            Dim parameters As ListDictionary = New ListDictionary()
            parameters.Add(_PRODUCTOS.Parameters.CodProducto, CodProducto)


            Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_PRODUCTOSLoadByPrimaryKey]", parameters)

        End Function

#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property CodProducto As SqlParameter
                Get
                    Return New SqlParameter("@CodProducto", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property DescProducto As SqlParameter
                Get
                    Return New SqlParameter("@DescProducto", SqlDbType.NVarChar, 100)
                End Get
            End Property

            Public Shared ReadOnly Property CantExistente As SqlParameter
                Get
                    Return New SqlParameter("@CantExistente", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CantMin As SqlParameter
                Get
                    Return New SqlParameter("@CantMin", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CantMax As SqlParameter
                Get
                    Return New SqlParameter("@CantMax", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodUniMedida As SqlParameter
                Get
                    Return New SqlParameter("@CodUniMedida", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodTipoProducto As SqlParameter
                Get
                    Return New SqlParameter("@CodTipoProducto", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Utilidad As SqlParameter
                Get
                    Return New SqlParameter("@Utilidad", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CostoMano As SqlParameter
                Get
                    Return New SqlParameter("@CostoMano", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property PrecioVenta As SqlParameter
                Get
                    Return New SqlParameter("@PrecioVenta", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property TotalMateriales As SqlParameter
                Get
                    Return New SqlParameter("@TotalMateriales", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property PorcUtilidad As SqlParameter
                Get
                    Return New SqlParameter("@PorcUtilidad", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodUsuario As SqlParameter
                Get
                    Return New SqlParameter("@CodUsuario", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property FechaActualizacion As SqlParameter
                Get
                    Return New SqlParameter("@FechaActualizacion", SqlDbType.DateTime, 0)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const CodProducto As String = "CodProducto"
            Public Const DescProducto As String = "DescProducto"
            Public Const CantExistente As String = "CantExistente"
            Public Const CantMin As String = "CantMin"
            Public Const CantMax As String = "CantMax"
            Public Const CodUniMedida As String = "CodUniMedida"
            Public Const CodTipoProducto As String = "CodTipoProducto"
            Public Const Utilidad As String = "Utilidad"
            Public Const CostoMano As String = "CostoMano"
            Public Const PrecioVenta As String = "PrecioVenta"
            Public Const TotalMateriales As String = "TotalMateriales"
            Public Const PorcUtilidad As String = "PorcUtilidad"
            Public Const CodUsuario As String = "codUsuario"
            Public Const FechaActualizacion As String = "fechaActualizacion"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodProducto) = _PRODUCTOS.PropertyNames.CodProducto
                    ht(DescProducto) = _PRODUCTOS.PropertyNames.DescProducto
                    ht(CantExistente) = _PRODUCTOS.PropertyNames.CantExistente
                    ht(CantMin) = _PRODUCTOS.PropertyNames.CantMin
                    ht(CantMax) = _PRODUCTOS.PropertyNames.CantMax
                    ht(CodUniMedida) = _PRODUCTOS.PropertyNames.CodUniMedida
                    ht(CodTipoProducto) = _PRODUCTOS.PropertyNames.CodTipoProducto
                    ht(Utilidad) = _PRODUCTOS.PropertyNames.Utilidad
                    ht(CostoMano) = _PRODUCTOS.PropertyNames.CostoMano
                    ht(PrecioVenta) = _PRODUCTOS.PropertyNames.PrecioVenta
                    ht(TotalMateriales) = _PRODUCTOS.PropertyNames.TotalMateriales
                    ht(PorcUtilidad) = _PRODUCTOS.PropertyNames.PorcUtilidad
                    ht(CodUsuario) = _PRODUCTOS.PropertyNames.CodUsuario
                    ht(FechaActualizacion) = _PRODUCTOS.PropertyNames.FechaActualizacion

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const CodProducto As String = "CodProducto"
            Public Const DescProducto As String = "DescProducto"
            Public Const CantExistente As String = "CantExistente"
            Public Const CantMin As String = "CantMin"
            Public Const CantMax As String = "CantMax"
            Public Const CodUniMedida As String = "CodUniMedida"
            Public Const CodTipoProducto As String = "CodTipoProducto"
            Public Const Utilidad As String = "Utilidad"
            Public Const CostoMano As String = "CostoMano"
            Public Const PrecioVenta As String = "PrecioVenta"
            Public Const TotalMateriales As String = "TotalMateriales"
            Public Const PorcUtilidad As String = "PorcUtilidad"
            Public Const CodUsuario As String = "CodUsuario"
            Public Const FechaActualizacion As String = "FechaActualizacion"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodProducto) = _PRODUCTOS.ColumnNames.CodProducto
                    ht(DescProducto) = _PRODUCTOS.ColumnNames.DescProducto
                    ht(CantExistente) = _PRODUCTOS.ColumnNames.CantExistente
                    ht(CantMin) = _PRODUCTOS.ColumnNames.CantMin
                    ht(CantMax) = _PRODUCTOS.ColumnNames.CantMax
                    ht(CodUniMedida) = _PRODUCTOS.ColumnNames.CodUniMedida
                    ht(CodTipoProducto) = _PRODUCTOS.ColumnNames.CodTipoProducto
                    ht(Utilidad) = _PRODUCTOS.ColumnNames.Utilidad
                    ht(CostoMano) = _PRODUCTOS.ColumnNames.CostoMano
                    ht(PrecioVenta) = _PRODUCTOS.ColumnNames.PrecioVenta
                    ht(TotalMateriales) = _PRODUCTOS.ColumnNames.TotalMateriales
                    ht(PorcUtilidad) = _PRODUCTOS.ColumnNames.PorcUtilidad
                    ht(CodUsuario) = _PRODUCTOS.ColumnNames.CodUsuario
                    ht(FechaActualizacion) = _PRODUCTOS.ColumnNames.FechaActualizacion

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const CodProducto As String = "s_CodProducto"
            Public Const DescProducto As String = "s_DescProducto"
            Public Const CantExistente As String = "s_CantExistente"
            Public Const CantMin As String = "s_CantMin"
            Public Const CantMax As String = "s_CantMax"
            Public Const CodUniMedida As String = "s_CodUniMedida"
            Public Const CodTipoProducto As String = "s_CodTipoProducto"
            Public Const Utilidad As String = "s_Utilidad"
            Public Const CostoMano As String = "s_CostoMano"
            Public Const PrecioVenta As String = "s_PrecioVenta"
            Public Const TotalMateriales As String = "s_TotalMateriales"
            Public Const PorcUtilidad As String = "s_PorcUtilidad"
            Public Const CodUsuario As String = "s_CodUsuario"
            Public Const FechaActualizacion As String = "s_FechaActualizacion"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property CodProducto As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodProducto)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodProducto, Value)
            End Set
        End Property

        Public Overridable Property DescProducto As String
            Get
                Return MyBase.Getstring(ColumnNames.DescProducto)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.DescProducto, Value)
            End Set
        End Property

        Public Overridable Property CantExistente As Integer
            Get
                Return MyBase.Getint(ColumnNames.CantExistente)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CantExistente, Value)
            End Set
        End Property

        Public Overridable Property CantMin As Integer
            Get
                Return MyBase.Getint(ColumnNames.CantMin)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CantMin, Value)
            End Set
        End Property

        Public Overridable Property CantMax As Integer
            Get
                Return MyBase.Getint(ColumnNames.CantMax)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CantMax, Value)
            End Set
        End Property

        Public Overridable Property CodUniMedida As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodUniMedida)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodUniMedida, Value)
            End Set
        End Property

        Public Overridable Property CodTipoProducto As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodTipoProducto)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodTipoProducto, Value)
            End Set
        End Property

        Public Overridable Property Utilidad As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.Utilidad)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.Utilidad, Value)
            End Set
        End Property

        Public Overridable Property CostoMano As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.CostoMano)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.CostoMano, Value)
            End Set
        End Property

        Public Overridable Property PrecioVenta As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.PrecioVenta)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.PrecioVenta, Value)
            End Set
        End Property

        Public Overridable Property TotalMateriales As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.TotalMateriales)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.TotalMateriales, Value)
            End Set
        End Property

        Public Overridable Property PorcUtilidad As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.PorcUtilidad)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.PorcUtilidad, Value)
            End Set
        End Property

        Public Overridable Property CodUsuario As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodUsuario)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodUsuario, Value)
            End Set
        End Property

        Public Overridable Property FechaActualizacion As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.FechaActualizacion)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.FechaActualizacion, Value)
            End Set
        End Property


#End Region
	
	#Region "String Properties" 

		Public Overridable Property s_CodProducto As String
			Get
				If Me.IsColumnNull(ColumnNames.CodProducto) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodProducto)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodProducto)
				Else
					Me.CodProducto = MyBase.SetintAsString(ColumnNames.CodProducto, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_DescProducto As String
			Get
				If Me.IsColumnNull(ColumnNames.DescProducto) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.DescProducto)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.DescProducto)
				Else
					Me.DescProducto = MyBase.SetstringAsString(ColumnNames.DescProducto, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantExistente As String
			Get
				If Me.IsColumnNull(ColumnNames.CantExistente) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CantExistente)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantExistente)
				Else
					Me.CantExistente = MyBase.SetintAsString(ColumnNames.CantExistente, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantMin As String
			Get
				If Me.IsColumnNull(ColumnNames.CantMin) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CantMin)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantMin)
				Else
					Me.CantMin = MyBase.SetintAsString(ColumnNames.CantMin, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantMax As String
			Get
				If Me.IsColumnNull(ColumnNames.CantMax) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CantMax)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantMax)
				Else
					Me.CantMax = MyBase.SetintAsString(ColumnNames.CantMax, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodUniMedida As String
			Get
				If Me.IsColumnNull(ColumnNames.CodUniMedida) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodUniMedida)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodUniMedida)
				Else
					Me.CodUniMedida = MyBase.SetintAsString(ColumnNames.CodUniMedida, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodTipoProducto As String
			Get
				If Me.IsColumnNull(ColumnNames.CodTipoProducto) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodTipoProducto)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodTipoProducto)
				Else
					Me.CodTipoProducto = MyBase.SetintAsString(ColumnNames.CodTipoProducto, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Utilidad As String
			Get
				If Me.IsColumnNull(ColumnNames.Utilidad) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.Utilidad)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Utilidad)
				Else
					Me.Utilidad = MyBase.SetdecimalAsString(ColumnNames.Utilidad, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CostoMano As String
			Get
				If Me.IsColumnNull(ColumnNames.CostoMano) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.CostoMano)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CostoMano)
				Else
					Me.CostoMano = MyBase.SetdecimalAsString(ColumnNames.CostoMano, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_PrecioVenta As String
			Get
				If Me.IsColumnNull(ColumnNames.PrecioVenta) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.PrecioVenta)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.PrecioVenta)
				Else
					Me.PrecioVenta = MyBase.SetdecimalAsString(ColumnNames.PrecioVenta, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_TotalMateriales As String
			Get
				If Me.IsColumnNull(ColumnNames.TotalMateriales) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.TotalMateriales)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.TotalMateriales)
				Else
					Me.TotalMateriales = MyBase.SetdecimalAsString(ColumnNames.TotalMateriales, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_PorcUtilidad As String
			Get
				If Me.IsColumnNull(ColumnNames.PorcUtilidad) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.PorcUtilidad)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.PorcUtilidad)
				Else
					Me.PorcUtilidad = MyBase.SetdecimalAsString(ColumnNames.PorcUtilidad, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodUsuario As String
			Get
				If Me.IsColumnNull(ColumnNames.CodUsuario) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodUsuario)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodUsuario)
				Else
					Me.CodUsuario = MyBase.SetintAsString(ColumnNames.CodUsuario, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_FechaActualizacion As String
			Get
				If Me.IsColumnNull(ColumnNames.FechaActualizacion) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.FechaActualizacion)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.FechaActualizacion)
				Else
					Me.FechaActualizacion = MyBase.SetDateTimeAsString(ColumnNames.FechaActualizacion, Value)
				End If
			End Set
		End Property


	#End Region  	

	#Region "Where Clause"
    Public Class WhereClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffWhereParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffWhereParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "TearOff's"
		Public class TearOffWhereParameter

			Public Sub New(ByVal clause As WhereClause)
				Me._clause = clause
			End Sub
		
	
			Public ReadOnly Property CodProducto() As WhereParameter
				Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodProducto, Parameters.CodProducto)
                        Me._clause._entity.Query.AddWhereParameter(where)
					Return where
				End Get
			End Property

			Public ReadOnly Property DescProducto() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.DescProducto, Parameters.DescProducto)
                        Me._clause._entity.Query.AddWhereParameter(where)
					Return where
				End Get
			End Property

			Public ReadOnly Property CantExistente() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.CantExistente, Parameters.CantExistente)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CantMin() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CantMin, Parameters.CantMin)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CantMax() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CantMax, Parameters.CantMax)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodUniMedida() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodUniMedida, Parameters.CodUniMedida)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodTipoProducto() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodTipoProducto, Parameters.CodTipoProducto)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Utilidad() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Utilidad, Parameters.Utilidad)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CostoMano() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CostoMano, Parameters.CostoMano)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property PrecioVenta() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.PrecioVenta, Parameters.PrecioVenta)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property TotalMateriales() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.TotalMateriales, Parameters.TotalMateriales)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property PorcUtilidad() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.PorcUtilidad, Parameters.PorcUtilidad)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodUsuario() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FechaActualizacion() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property


			Private _clause as WhereClause
		End Class
		#End Region	

		Public ReadOnly Property CodProducto() As WhereParameter 
			Get
				If _CodProducto_W Is Nothing Then
					_CodProducto_W = TearOff.CodProducto
				End If
				Return _CodProducto_W
			End Get
		End Property

		Public ReadOnly Property DescProducto() As WhereParameter 
			Get
				If _DescProducto_W Is Nothing Then
					_DescProducto_W = TearOff.DescProducto
				End If
				Return _DescProducto_W
			End Get
		End Property

		Public ReadOnly Property CantExistente() As WhereParameter 
			Get
				If _CantExistente_W Is Nothing Then
					_CantExistente_W = TearOff.CantExistente
				End If
				Return _CantExistente_W
			End Get
		End Property

		Public ReadOnly Property CantMin() As WhereParameter 
			Get
				If _CantMin_W Is Nothing Then
					_CantMin_W = TearOff.CantMin
				End If
				Return _CantMin_W
			End Get
		End Property

		Public ReadOnly Property CantMax() As WhereParameter 
			Get
				If _CantMax_W Is Nothing Then
					_CantMax_W = TearOff.CantMax
				End If
				Return _CantMax_W
			End Get
		End Property

		Public ReadOnly Property CodUniMedida() As WhereParameter 
			Get
				If _CodUniMedida_W Is Nothing Then
					_CodUniMedida_W = TearOff.CodUniMedida
				End If
				Return _CodUniMedida_W
			End Get
		End Property

		Public ReadOnly Property CodTipoProducto() As WhereParameter 
			Get
				If _CodTipoProducto_W Is Nothing Then
					_CodTipoProducto_W = TearOff.CodTipoProducto
				End If
				Return _CodTipoProducto_W
			End Get
		End Property

		Public ReadOnly Property Utilidad() As WhereParameter 
			Get
				If _Utilidad_W Is Nothing Then
					_Utilidad_W = TearOff.Utilidad
				End If
				Return _Utilidad_W
			End Get
		End Property

		Public ReadOnly Property CostoMano() As WhereParameter 
			Get
				If _CostoMano_W Is Nothing Then
					_CostoMano_W = TearOff.CostoMano
				End If
				Return _CostoMano_W
			End Get
		End Property

		Public ReadOnly Property PrecioVenta() As WhereParameter 
			Get
				If _PrecioVenta_W Is Nothing Then
					_PrecioVenta_W = TearOff.PrecioVenta
				End If
				Return _PrecioVenta_W
			End Get
		End Property

		Public ReadOnly Property TotalMateriales() As WhereParameter 
			Get
				If _TotalMateriales_W Is Nothing Then
					_TotalMateriales_W = TearOff.TotalMateriales
				End If
				Return _TotalMateriales_W
			End Get
		End Property

		Public ReadOnly Property PorcUtilidad() As WhereParameter 
			Get
				If _PorcUtilidad_W Is Nothing Then
					_PorcUtilidad_W = TearOff.PorcUtilidad
				End If
				Return _PorcUtilidad_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As WhereParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As WhereParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodProducto_W As WhereParameter = Nothing
		Private _DescProducto_W As WhereParameter = Nothing
		Private _CantExistente_W As WhereParameter = Nothing
		Private _CantMin_W As WhereParameter = Nothing
		Private _CantMax_W As WhereParameter = Nothing
		Private _CodUniMedida_W As WhereParameter = Nothing
		Private _CodTipoProducto_W As WhereParameter = Nothing
		Private _Utilidad_W As WhereParameter = Nothing
		Private _CostoMano_W As WhereParameter = Nothing
		Private _PrecioVenta_W As WhereParameter = Nothing
		Private _TotalMateriales_W As WhereParameter = Nothing
		Private _PorcUtilidad_W As WhereParameter = Nothing
		Private _CodUsuario_W As WhereParameter = Nothing
		Private _FechaActualizacion_W As WhereParameter = Nothing

			Public Sub WhereClauseReset()

			_CodProducto_W = Nothing
			_DescProducto_W = Nothing
			_CantExistente_W = Nothing
			_CantMin_W = Nothing
			_CantMax_W = Nothing
			_CodUniMedida_W = Nothing
			_CodTipoProducto_W = Nothing
			_Utilidad_W = Nothing
			_CostoMano_W = Nothing
			_PrecioVenta_W = Nothing
			_TotalMateriales_W = Nothing
			_PorcUtilidad_W = Nothing
			_CodUsuario_W = Nothing
			_FechaActualizacion_W = Nothing
				Me._entity.Query.FlushWhereParameters()

			End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffWhereParameter
    End Class	

	Public ReadOnly Property Where() As WhereClause
		Get
			If _whereClause Is Nothing Then
				_whereClause = New WhereClause(Me)
			End If
	
			Return _whereClause
		End Get
	End Property
	
	Private _whereClause As WhereClause = Nothing	
#End Region	

#Region "Aggregate Clause"
    Public Class AggregateClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffAggregateParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffAggregateParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "AggregateParameter TearOff's"
		Public class TearOffAggregateParameter

			Public Sub New(ByVal clause As AggregateClause)
				Me._clause = clause
			End Sub
		
	
		Public ReadOnly Property CodProducto() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodProducto, Parameters.CodProducto)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property DescProducto() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.DescProducto, Parameters.DescProducto)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantExistente() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantExistente, Parameters.CantExistente)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantMin() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantMin, Parameters.CantMin)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantMax() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantMax, Parameters.CantMax)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodUniMedida() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodUniMedida, Parameters.CodUniMedida)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodTipoProducto() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodTipoProducto, Parameters.CodTipoProducto)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Utilidad() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Utilidad, Parameters.Utilidad)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CostoMano() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CostoMano, Parameters.CostoMano)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property PrecioVenta() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.PrecioVenta, Parameters.PrecioVenta)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property TotalMateriales() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.TotalMateriales, Parameters.TotalMateriales)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property PorcUtilidad() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.PorcUtilidad, Parameters.PorcUtilidad)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property


			Private _clause as AggregateClause
		End Class
		#End Region	

		Public ReadOnly Property CodProducto() As AggregateParameter 
			Get
				If _CodProducto_W Is Nothing Then
					_CodProducto_W = TearOff.CodProducto
				End If
				Return _CodProducto_W
			End Get
		End Property

		Public ReadOnly Property DescProducto() As AggregateParameter 
			Get
				If _DescProducto_W Is Nothing Then
					_DescProducto_W = TearOff.DescProducto
				End If
				Return _DescProducto_W
			End Get
		End Property

		Public ReadOnly Property CantExistente() As AggregateParameter 
			Get
				If _CantExistente_W Is Nothing Then
					_CantExistente_W = TearOff.CantExistente
				End If
				Return _CantExistente_W
			End Get
		End Property

		Public ReadOnly Property CantMin() As AggregateParameter 
			Get
				If _CantMin_W Is Nothing Then
					_CantMin_W = TearOff.CantMin
				End If
				Return _CantMin_W
			End Get
		End Property

		Public ReadOnly Property CantMax() As AggregateParameter 
			Get
				If _CantMax_W Is Nothing Then
					_CantMax_W = TearOff.CantMax
				End If
				Return _CantMax_W
			End Get
		End Property

		Public ReadOnly Property CodUniMedida() As AggregateParameter 
			Get
				If _CodUniMedida_W Is Nothing Then
					_CodUniMedida_W = TearOff.CodUniMedida
				End If
				Return _CodUniMedida_W
			End Get
		End Property

		Public ReadOnly Property CodTipoProducto() As AggregateParameter 
			Get
				If _CodTipoProducto_W Is Nothing Then
					_CodTipoProducto_W = TearOff.CodTipoProducto
				End If
				Return _CodTipoProducto_W
			End Get
		End Property

		Public ReadOnly Property Utilidad() As AggregateParameter 
			Get
				If _Utilidad_W Is Nothing Then
					_Utilidad_W = TearOff.Utilidad
				End If
				Return _Utilidad_W
			End Get
		End Property

		Public ReadOnly Property CostoMano() As AggregateParameter 
			Get
				If _CostoMano_W Is Nothing Then
					_CostoMano_W = TearOff.CostoMano
				End If
				Return _CostoMano_W
			End Get
		End Property

		Public ReadOnly Property PrecioVenta() As AggregateParameter 
			Get
				If _PrecioVenta_W Is Nothing Then
					_PrecioVenta_W = TearOff.PrecioVenta
				End If
				Return _PrecioVenta_W
			End Get
		End Property

		Public ReadOnly Property TotalMateriales() As AggregateParameter 
			Get
				If _TotalMateriales_W Is Nothing Then
					_TotalMateriales_W = TearOff.TotalMateriales
				End If
				Return _TotalMateriales_W
			End Get
		End Property

		Public ReadOnly Property PorcUtilidad() As AggregateParameter 
			Get
				If _PorcUtilidad_W Is Nothing Then
					_PorcUtilidad_W = TearOff.PorcUtilidad
				End If
				Return _PorcUtilidad_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodProducto_W As AggregateParameter = Nothing
		Private _DescProducto_W As AggregateParameter = Nothing
		Private _CantExistente_W As AggregateParameter = Nothing
		Private _CantMin_W As AggregateParameter = Nothing
		Private _CantMax_W As AggregateParameter = Nothing
		Private _CodUniMedida_W As AggregateParameter = Nothing
		Private _CodTipoProducto_W As AggregateParameter = Nothing
		Private _Utilidad_W As AggregateParameter = Nothing
		Private _CostoMano_W As AggregateParameter = Nothing
		Private _PrecioVenta_W As AggregateParameter = Nothing
		Private _TotalMateriales_W As AggregateParameter = Nothing
		Private _PorcUtilidad_W As AggregateParameter = Nothing
		Private _CodUsuario_W As AggregateParameter = Nothing
		Private _FechaActualizacion_W As AggregateParameter = Nothing

		Public Sub AggregateClauseReset()

		_CodProducto_W = Nothing
		_DescProducto_W = Nothing
		_CantExistente_W = Nothing
		_CantMin_W = Nothing
		_CantMax_W = Nothing
		_CodUniMedida_W = Nothing
		_CodTipoProducto_W = Nothing
		_Utilidad_W = Nothing
		_CostoMano_W = Nothing
		_PrecioVenta_W = Nothing
		_TotalMateriales_W = Nothing
		_PorcUtilidad_W = Nothing
		_CodUsuario_W = Nothing
		_FechaActualizacion_W = Nothing
			Me._entity.Query.FlushAggregateParameters()

		End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffAggregateParameter
    End Class	

	Public ReadOnly Property Aggregate() As AggregateClause
		Get
			If _aggregateClause Is Nothing Then
				_aggregateClause = New AggregateClause(Me)
			End If
	
			Return _aggregateClause
		End Get
	End Property
	
	Private _aggregateClause As AggregateClause = Nothing	
#End Region	

	Protected Overrides Function GetInsertCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_PRODUCTOSInsert]" 
	    
		CreateParameters(cmd)
		
		Dim p As SqlParameter
		p = cmd.Parameters(Parameters.CodProducto.ParameterName)
		p.Direction = ParameterDirection.Output
    
		Return cmd 

  	End Function
	
	Protected Overrides Function GetUpdateCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_PRODUCTOSUpdate]" 
		
		CreateParameters(cmd) 
		    
		Return cmd
	
	End Function	
	
	Protected Overrides Function GetDeleteCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_PRODUCTOSDelete]" 
		
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodProducto)
		p.SourceColumn = ColumnNames.CodProducto
		p.SourceVersion = DataRowVersion.Current

  
		Return cmd
	
	End Function	
	
	Private Sub CreateParameters(ByVal cmd As SqlCommand)
	
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodProducto)
		p.SourceColumn = ColumnNames.CodProducto
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.DescProducto)
		p.SourceColumn = ColumnNames.DescProducto
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantExistente)
		p.SourceColumn = ColumnNames.CantExistente
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantMin)
		p.SourceColumn = ColumnNames.CantMin
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantMax)
		p.SourceColumn = ColumnNames.CantMax
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodUniMedida)
		p.SourceColumn = ColumnNames.CodUniMedida
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodTipoProducto)
		p.SourceColumn = ColumnNames.CodTipoProducto
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Utilidad)
		p.SourceColumn = ColumnNames.Utilidad
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CostoMano)
		p.SourceColumn = ColumnNames.CostoMano
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.PrecioVenta)
		p.SourceColumn = ColumnNames.PrecioVenta
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.TotalMateriales)
		p.SourceColumn = ColumnNames.TotalMateriales
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.PorcUtilidad)
		p.SourceColumn = ColumnNames.PorcUtilidad
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodUsuario)
		p.SourceColumn = ColumnNames.CodUsuario
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.FechaActualizacion)
		p.SourceColumn = ColumnNames.FechaActualizacion
		p.SourceVersion = DataRowVersion.Current


	End Sub	

End Class

End NameSpace

